import React from 'react'
import { connect } from 'dva'
import { routerRedux } from 'dva/router'
import { Tabs, Button } from 'antd';
import ChargeManage from './components/ChargeManage'
import Gift from './components/Gift'
import InterestRate from './components/InterestRate'
import Reward from './components/Reward'
import styles from './index.less'

const TabPane = Tabs.TabPane;

@connect(({ activities, loading }) => ({
  activities,
  loading: loading.models.activities,
}))

class Setting extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
    }
  }

  onReviseOk = (data) =>{
    this.props.dispatch({
      type:"activities/updateRechargeConfig",
      payload:data
    })
  }

  onWelfareReviseOk = (data) =>{
    this.props.dispatch({
      type:"activities/updateWelfareConfig",
      payload:data
    })
  }

  onGiftReviseOk = (data) => {
    this.props.dispatch({
      type:"activities/updateGiftConfig",
      payload:data
    })
  }

  onRewardOk = (data)=>{
    this.props.dispatch({
      type:"activities/updateInviteRewardsConfig",
      payload:data
    })
  }



  render() {
    const { chargeItem , welfareItem, giftItem, rewardItem} = this.props.activities

    return (
      <div className={styles.activity_set}>
        <Tabs defaultActiveKey="1">
          <TabPane tab="充值管理" key="1">
              <div className={styles.ChargeManage}>
                <ChargeManage
                onReviseOk={this.onReviseOk}
                chargeItem={chargeItem} />
              </div>
          </TabPane>
          <TabPane tab="福利金利率" key="2">
              <div className={styles.InterestRate}>
                <InterestRate
                onWelfareReviseOk={this.onWelfareReviseOk}
                welfareItem={welfareItem} />
              </div>
          </TabPane>
          <TabPane tab="礼券兑换" key="3">
              <div className={styles.Gift}>
              <Gift
              onGiftReviseOk={this.onGiftReviseOk}
              giftItem={giftItem}/>
              </div>
          </TabPane>
          <TabPane tab="好友邀请奖励" key="4">
              <div className={styles.Reward}>
              <Reward
              onRewardOk={this.onRewardOk}
              rewardItem={rewardItem}/>
            </div>
          </TabPane>
        </Tabs>
         
         
         
         
      </div>
    );
  }
};

export default Setting
